url = "https://www.health.ny.gov/statistics/vital_statistics/2019/table22.htm"
induced_abortion_2019 =
read_html(url) %>%
html_table(header = FALSE) %>%
first() %>%
janitor::clean_names()
data cleaning
url = "https://www.health.ny.gov/statistics/vital_statistics/2018/table22.htm"
induced_abortion_2018 =
read_html(url) %>%
html_table(header = FALSE) %>%
first() %>%
janitor::clean_names()
data cleaning
url = "https://www.health.ny.gov/statistics/vital_statistics/2018/table22.htm"
induced_abortion_2017 =
read_html(url) %>%
html_table(header = FALSE) %>%
first() %>%
janitor::clean_names()
data cleaning
url = "https://www.health.ny.gov/statistics/vital_statistics/2016/table22.htm"
induced_abortion_2016 =
read_html(url) %>%
html_table(header = FALSE) %>%
first() %>%
janitor::clean_names()
data cleaning
url = "https://www.health.ny.gov/statistics/vital_statistics/2015/table22.htm"
induced_abortion_2015 =
read_html(url) %>%
html_table(header = FALSE) %>%
first() %>%
janitor::clean_names()
data cleaning
url = "https://www.health.ny.gov/statistics/vital_statistics/2014/table22.htm"
induced_abortion_2014 =
read_html(url) %>%
html_table(header = FALSE) %>%
first() %>%
janitor::clean_names()
data cleaning
Merge all datasets
year_final =
rbind(clean_2019, clean_2018, clean_2017, clean_2016, clean_2015, clean_2014, by=c("borough", "total", "year")) %>%
select(year, everything()) %>%
filter(!year=="year") %>%
mutate_at(c("total", "year"), as.numeric)
plot_borough_year=year_final %>%
mutate(borough = fct_reorder(borough, total)) %>%
plot_ly(y = ~total, x=~year, color = ~borough, type = "scatter", mode="line", colors = "viridis") %>%
layout(title = 'Induced Abortions Year by Borough', yaxis = list(title = 'Number of Induced Abortions per 1,000 Live Births'))
plot_borough_year